<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>react_6_state简写</title>
</head>
<body>
    <div id="test1"></div>
    <div id="test2"></div>
    <div id="test3"></div>
    <div id="test4"></div>

    <!-- 引入react 核心库 -->
    <script type="text/javascript" src="./js/react.development.js"></script>
    <!-- 引入react-dom 用于支持react操作dom -->
    <script type="text/javascript" src="./js/react-dom.development.js"></script>
    <!-- 引入babel 用于讲jsx转成js -->
    <script type="text/javascript" src="./js/babel.min.js"></script>

    <!-- 组 件 -->
    <script type="text/babel">
        //props 从组件外部赋值
        class Persion extends React.Component{
            render() {
                //结构表达式
                const {name,age,gender} = this.props
                return (
                    <div>
                        <ul>
                            <li>姓名：{name}</li>
                            <li>年龄：{age}</li>
                            <li>性别：{gender}</li>
                        </ul>
                    </div>
                );
            }
        }
        //在标签中以属性的方式传参的时候，react会以kv的形式放入类中的props对象中
        ReactDOM.render(<Persion name='张三' age='18' gender='男'/>,document.getElementById('test1'))
        ReactDOM.render(<Persion name='李四' age='19' gender='男'/>,document.getElementById('test2'))
        ReactDOM.render(<Persion name='王五' age='20' gender='女'/>,document.getElementById('test3'))

        //当标签多的时候其实可以这么搞
        const p = {name:'小小',age:'18',gender:'女'}
        ReactDOM.render(<Persion {...p}/>,document.getElementById('test4'))
    </script>
</body>

</html>